package yt.demo.appcoresystem.impl;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yt.demo.appcommondb.base.BaseService;
import yt.demo.appcommondb.vo.ConditionVO;
import yt.demo.appcoresystem.entity.SystemDictType;
import yt.demo.appcoresystem.mapper.SystemDictTypeMapper;
import yt.demo.appcoresystem.service.ISystemDictTypeService;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class SystemDictTypeService extends BaseService<SystemDictType, SystemDictTypeMapper> implements ISystemDictTypeService {

    @Autowired
    public SystemDictTypeService(SystemDictTypeMapper mapper) {
        super(mapper, SystemDictType.class);
    }

    @Override
    protected List<ConditionVO<SystemDictType, ?>> whereConditions(SystemDictType params) {
        List<ConditionVO<SystemDictType, ?>> conditions = new ArrayList<>();
        if (ObjectUtil.isNotEmpty(params.getName())) {
            conditions.add(ConditionVO.createCondition(SystemDictType::getName, "like", params.getName()));
        }
        if (ObjectUtil.isNotEmpty(params.getCode())) {
            conditions.add(ConditionVO.createCondition(SystemDictType::getCode, "like", params.getCode()));
        }
        if (ObjectUtil.isNotEmpty(params.getStatus())) {
            conditions.add(ConditionVO.createCondition(SystemDictType::getStatus, "eq", params.getStatus()));
        }
        return conditions;
    }

}
